package com.gl.wxstore.store.service;

import java.util.List;

import com.gl.wxstore.common.utils.PageConstants;
import com.jfinal.aop.Before;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.activerecord.tx.Tx;

public class OrderService {

	@Before(Tx.class)
	public Page<Record> list(Integer pageNo) {
		String selectSql = "SELECT sp.id,sp.name,sp.description,sp.pic,sp.price ";
		StringBuilder fromSql = new StringBuilder("FROM store_product sp ");
		return Db.paginate(pageNo, PageConstants.PAGE_SIZE, selectSql, fromSql.toString());
	}

	public List<Record> listOrderProduct(String id) {
		// TODO Auto-generated method stub
		String sql = "SELECT sc.id,sp.name AS name,sc.count,sp.price AS price FROM store_product sp,store_cart sc "
				+ "WHERE sc.store_product_id = sp.id AND sc.sys_user_id =? AND sc.state = 1";
		return Db.find(sql, id);
	}

}
